package com.itcms.webservice.util;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

import com.itcms.common.util.DateUtil;

public class Md5 {
	public static void main(String[] args) {

		String password = "111111";
		String timestamp = "2014-02-28 15:42:57";
		System.out.println(md5ComputeDigest(md5ComputeDigest(password)
				+ timestamp));
	}

	public static String md5Secret(String timestamp) {
		String password = "111111";
		return md5ComputeDigest(md5ComputeDigest(password)+ timestamp);
	}
	
	public static String md5ComputeDigest(String str) {
		String d = "";
		try {
			MessageDigest md = MessageDigest.getInstance("MD5");
			md.reset();
			md.update(str.getBytes());
			byte[] hash = md.digest();
			
			for (int i = 0; i < hash.length; i++) {
				int v = hash[i] & 0xFF;
				if (v < 16)
					d += "0";
				d += Integer.toString(v, 16).toUpperCase() + "";
			}
		} catch (NoSuchAlgorithmException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		return d;
	}
}
